$(function () {
    var showUrl = '/person/getPerson?token='+localStorage.getItem('token');
    var logoutUrl = '/person/logout?token='+localStorage.getItem('token');
    //显示相关的信息
    showinfo();
    function showinfo(){
        $.getJSON(showUrl,function (data){
            if (data.success){
                //头像
                $('#headImg').attr('src',getContextPath()+data.data.headImg);
                //用户名
                $('#username').html(data.data.username);
                //手机号
                var phone = data.data.phone;
                if (phone==null||phone==''){
                    $('#bindmobile').text('未绑定');
                    $('#bindhref').attr('href','/probe/frontend/bindMobile');
                }else {
                    $('#bindmobile').text('已绑定');
                }
                $('#phone').html(data.data.phone);
            }
        });
    }
    //退出账号,返回到登录界面
    $('#exit').click(function () {
        if (confirm('确定要退出?')) {
            $.getJSON(logoutUrl,function (data) {
                if (data.success){
                    localStorage.removeItem('token');
                }
                window.location.href = '/login';
            });
        }
    });
    //返回个人中心
    $('.bxg-back').click(function () {
       window.location.href = '/person/personCenter';
    });
    //个人信息
    $('.user-info').click(function () {
       window.location.href = '/person/personData';
    });
});
